<?php
	class MessageController
	{
		// Membervariables
		private $_userHandler = null;
		private $_messView = null;
		private $_messHandler = null;
				
		public function __construct(\UserHandler $userHandler, \MessageView $messView, \MessageHandler $messHandler)
		{
			$this->_userHandler = $userHandler;
			$this->_messView = $messView;
			$this->_messHandler = $messHandler;
		}
		
		public function DoControl()
		{
			$xhtml = "";	
			
			// Get a messageid.
			$messageId = $this->_messView->GetMessageId();
			
			// Get the messageobject.
			$message = $this->_messHandler->GetMessage($messageId);
			
			// Check if the message has been read before or not.			
			if ($message->readstatus == 0)
			{
				$this->_messHandler->MarkAMessageAsRead($message->messageid);
			}
			$xhtml .= $this->_messView->PrintMessage($message);
			
			return $xhtml;
		}
	}